/**
 * Copyright (c) 2012 Ibrahim Abd Elkader 
 * Email: <i.abdalkader@gmail.com> 
 * Licensed under the MIT license.
 * See the file COPYING for copying permission.
 */
#ifndef __UTASK__
#define __UTASK__
#include "sched.h"
#include "uthash.h"
#include <ucontext.h>
struct task_t {
    /* task id */
    int id;
    /* keeps track of the ticks */
    long ticks;
    /* marks the task for removal */
    int remove;
    /* ucontext */
    ucontext_t uctx;
    /* make it hashable */
    UT_hash_handle hh;
};

typedef void (*task_callback)(void *arg);
int  utask_init(struct sched_t *sched);
int  utask_create(task_callback cb, void *arg, int ss_size);
void utask_destroy();
void utask_run();
void utask_yield();
long utask_time_us();
#endif//__UTASK__
